package flextv.data {

import flash.data.SQLResult;
import flash.errors.SQLError;
import flash.net.Responder;

import flextv.core.vo.Playlist;

import mx.collections.ArrayCollection;


internal class PlaylistResponder extends Responder {
	
	private var playlists: ArrayCollection;
	
	
	public function PlaylistResponder() {
		super(buildPlaylistsResult, logError);
	}
	
	
	public function buildPlaylistsResult(result: SQLResult): void{
		this.playlists = new ArrayCollection();
 
		if(result != null && result.data != null) {
			for(var i: int = 0; i < result.data.length; i++) {
				this.playlists.addItem(Playlist(result.data[i]));
			}
		}
	}
 
	public function logError(error: SQLError):void{
		throw new Error(error.toString());
	}		
 
	public function getPlaylists(): ArrayCollection{
		return this.playlists;
	}
	
}
}